/*
day210
2020.3.35
*/ 
#include<iostream>
#include<vector>
#include<string>
using namespace std;

 
class Solution {
public:
    string findLongestWord(string s, vector<string>& d) {
    	string res="";
        for(int i=0;i<d.size();++i)
        {
        	string tem=d[i];
        	if(tem.size()<res.size() || tem.size()>s.size())
        	{
        		continue;
			}
		
			if(is_match(s,tem))
			{
				if(tem.size()>res.size() || tem<res)
				{
					res=tem;
				}
			}
		}
		return res;
    }
    
    bool is_match(string s,string str)
    {
    	int j=0;
    	for(int i=0;i<str.size();++i)
    	{
    		while(j<s.size() && s[j]!=str[i])
    		{
    			++j;
			}
			if(j==s.size())
			{
				return false;
			}
		}
		return true;
	}
};


int main()
{
	Solution sol;
	string s = "wsmzffsupzgauxwokahurhhikapmqitytvcgrfpavbxbmmzdhnrazartkzrnsmoovmiofmilihynvqlmwcihkfskwozyjlnpkgdkayioieztjswgwckmuqnhbvsfoevdynyejihombjppgdgjbqtlauoapqldkuhfbynopisrjsdelsfspzcknfwuwdcgnaxpevwodoegzeisyrlrfqqavfziermslnlclbaejzqglzjzmuprpksjpqgnohjjrpdlofruutojzfmianxsbzfeuabhgeflyhjnyugcnhteicsvjajludwizklkkosrpvhhrgkzctzwcghpxnbsmkxfydkvfevyewqnzniofhsriadsoxjmsswgpiabcbpdjjuffnbvoiwotrbvylmnryckpnyemzkiofwdnpnbhkapsktrkkkakxetvdpfkdlwqhfjyhvlxgywavtmezbgpobhikrnebmevthlzgajyrmnbougmrirsxi";
	vector<string> d = {"ale","apple","monkey","plea"};
//	cout<<sol.findLongestWord(s,d)<<endl;
//	cout<<sol.is_match(s,)<<endl;
	string s1="jpthiudqzzeugzwwsngebdeai";
	string s2="nbmxgkduynigvzuyblwjepn"; 
	cout<<s1.size()<<'\t'<<s2.size()<<endl;
	return 0;
}
